import api from '@/api/favorite/favoriteIndex'

import { PreData, FavListApiModel } from '@/type/favorite/favorite';


export const favoriteList = (): RES<FavListApiModel> => api.get('/favoriteList', {
    withCredentials: true
});

export const isFav = (url: string): RES<{ res: boolean }> => api.get('/isFavorite', {
    params: { url: url },
    withCredentials: true
});

export const addFavUrl = (params: { favUrlName: string, favoriteId: string, url: string }): RES<{ res: boolean }> => api.post('/addFavUrl', params, {
    withCredentials: true,
})

export const getAgentRes = (params: { url: string }): RES<{ favoriteId: string, favUrlName: string, favName:string }> => api.post('/collect', params, {
    withCredentials: true,
})


export const tidy = ():RES<{res:string}> => api.post('/tidy',null,{
    withCredentials: true,
})

export const  preViewTask = ():RES<any> => api.get('/previewTask',{
    withCredentials: true,
})

export const addFav = (param : {favoriteName:string,description:string}) : RES<{res:boolean}> => api.post('/addFavorite',param,{
    withCredentials: true,
})

export const removeUrl = (url:string):RES<{res:boolean}> => api.get('/removeUrl',{
    params : {url : url},
    withCredentials: true,
})

export const getDisorderedUrls = () : RES<{favUrls:{favUrlId:string,favUrlName:string,url:string}[]}> => api.get('/getDisorderedUrls',{
    withCredentials: true,
})

export const previewTask = ():RES<{data:PreData}> => api.get('/previewTask',{
    withCredentials: true,
})

export const acceptTask = ():RES<{res:boolean}> => api.post('/acceptTask',null,{
    withCredentials: true,
})